//
//  NYInstituteViewController.m
//  NiuWaJiaoYu
//
//  Created by MinLison on 2018/1/6.
//  Copyright © 2018年 niuwaketang. All rights reserved.
//

#import "NYInstituteViewController.h"
#import "NYPageViewController.h"

#import "NYIntroduceViewController.h"
#import "NYTeachersViewController.h"
#import "NYContactViewController.h"

@interface NYInstituteViewController () <WGPageViewControllerDelegate>

@property (nonatomic, strong) NYPageViewController *pageViewController;


@end

@implementation NYInstituteViewController

#pragma mark - Life Cycle Methods

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self initUI];
}
#pragma mark - Intial Methods
- (void)initUI {
    

}
- (void)initSubviews {
    
    [super initSubviews];
    [self configPageViewController];
}
- (void)configPageViewController
{
    self.pageViewController = [[NYPageViewController alloc] init];
    [self.pageViewController willMoveToParentViewController:self];
    [self addChildViewController:self.pageViewController];
    self.controllerView.pageViewController = self.pageViewController;
    [self.pageViewController didMoveToParentViewController:self];
    self.pageViewController.pageDelegate = self;
    self.pageViewController.topSortBottomLineColor = [UIColor clearColor];
    self.pageViewController.segmentControl.segmentWidthStyle = HMSegmentedControlSegmentWidthStyleFixed;
    self.pageViewController.segmentControl.selectedTitleTextAttributes = @{
                                                                           NSForegroundColorAttributeName : UIColorHex(0x5396F7),
                                                                           NSFontAttributeName : WGSystem14Font,
                                                                           };
    self.pageViewController.segmentControl.titleTextAttributes = @{
                                                                   NSForegroundColorAttributeName : UIColorHex(0x333333),
                                                                   NSFontAttributeName : WGSystem14Font,
                                                                   };
    self.pageViewController.segmentControl.selectionIndicatorEdgeInsets = UIEdgeInsetsMake(0, -3, 0, -3);
    self.pageViewController.segmentControl.selectionIndicatorColor = UIColorHex(0x0190D4);
    self.pageViewController.segmentTitles = @[@"研究院介绍",@"教师介绍",@"联系我们"];
}

#pragma mark - Network Methods

#pragma mark - Target Methods

#pragma mark - Public Methods

#pragma mark - Private Method
- (void)configNavigationBar:(BaseNavigationBar *)navigationBar {
    [super configNavigationBar:navigationBar];
    self.title = @"研究院介绍";
    
}
- (UIImage *)navigationBarShadowImage {
    return [UIImage imageWithColor:[UIColor clearColor]];
}

+ (NYViewControllerNavigationBarType)navigationBarType {

    return NYViewControllerNavigationBarTypeBlue;
}
- (void)refreshTheTeacherDataSource {
    
    NYTeachersViewController *viewController = (NYTeachersViewController *)[self.pageViewController contentControllerAtIndex:1];
    [(NYTeachersViewController *)viewController refreshTheDataSource];

//    for (UIViewController *viewController in self.pageViewController.viewControllerClasses) {
//
//        if ([viewController isKindOfClass:[NYTeachersViewController class]]) {
//
//            [(NYTeachersViewController *)viewController refreshTheDataSource];
//            break;
//        }
//    }
}

#pragma mark - External Delegate
/// MARK: - PageController Delegate
- (NSInteger)countOfContentItems {
    return 3;
}
- (UIViewController *)contentControllerAtIndex:(NSInteger)index {
    
    if (index == 0) {
        return [NYIntroduceViewController new];
    } else if (index == 1) {
        return [NYTeachersViewController new];
    }
    return [NYContactViewController new];
}
- (void)configController:(BaseViewController *)controller atIndex:(NSInteger)index {
    
}
- (void)controllerDidShow:(BaseViewController *)controller atIndex:(NSInteger)index {
    
}

- (BOOL)hasTopSegment {
    return true;
}

- (WGSegmentScrollDirection)scrollDirection {
    return WGSegmentScrollDirectionHorizontal;
}
#pragma mark - Setter Getter Methods

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
